using System;
using System.Runtime.CompilerServices;
using System.Threading;

namespace Beetle;

public abstract class Task : IDisposable
{
	private Timer m_a;

	private int m_b;

	private int m_c;

	[CompilerGenerated]
	private Exception d;

	[CompilerGenerated]
	private bool e;

	public Exception Error
	{
		[CompilerGenerated]
		get
		{
			return d;
		}
		[CompilerGenerated]
		internal set
		{
			d = value;
		}
	}

	public bool IsDisposed
	{
		[CompilerGenerated]
		get
		{
			return e;
		}
		[CompilerGenerated]
		private set
		{
			e = value;
		}
	}

	public Task()
	{
		IsDisposed = false;
	}

	private void c()
	{
		if (this.m_a != null && !IsDisposed)
		{
			this.m_a.Change(-1, -1);
		}
	}

	private void b()
	{
		if (this.m_a != null && !IsDisposed)
		{
			this.m_a.Change(this.m_b, this.m_c);
		}
	}

	public void Start(int dueTime, int period)
	{
		lock (this)
		{
			if (!IsDisposed)
			{
				this.m_b = dueTime;
				this.m_c = period;
				this.m_a = new Timer(a, null, dueTime, period);
			}
		}
	}

	private void a(object A_0)
	{
		c();
		Error = null;
		try
		{
			Execute();
		}
		catch (Exception ex)
		{
			Exception ex3 = (Error = ex);
		}
		finally
		{
			b();
		}
	}

	protected abstract void Execute();

	public void Dispose()
	{
		lock (this)
		{
			if (!IsDisposed)
			{
				IsDisposed = true;
			}
			if (this.m_a != null)
			{
				this.m_a.Dispose();
			}
		}
	}

	internal static string a()
	{
		return null;
	}
}
